package com.shoping.web.component.init;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * TODO
 *
 * @author zengweilong
 * @date 4/26/21 2:28 PM
 */
public class InitCarBean implements InitializingBean, DisposableBean {

    public void init() {
        System.out.println("this is init method");
    }

    public void init1() {
        System.out.println("this is init1 method");
    }

    /**
     * 优先Spring
     */
    @PostConstruct
    public void init2() {
        System.out.println("this is init2 @PostConstruct method");
    }

    public InitCarBean() {
        super();
        System.out.println("构造函数1");
    }

    public void destroy1() {
        System.out.println("this is destroy1 method");
    }

    /**
     * 优先Spring
     */
    @PreDestroy
    public void destroy2() {
        System.out.println("this is destroy2 @PreDestroy method");
    }

    @Override
    public void destroy() {
        System.out.println("this is destroy method");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        this.init();
    }
}
